package com.lagou.controller;

import com.lagou.commom.pojo.Products;
import com.lagou.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/products")
public class ProductsController {
    @Autowired
    private ProductService productService;

    @Value("${server.port}")
    private String port;

    @RequestMapping("/query/{id}")
    public Products query(@PathVariable("id") Integer id) {
        Products productById = productService.findProductById(id);
        return productById;
    }

    @RequestMapping("/getPort")
    public String getPort(){
        return this.port;
    }
}
